//
// CLandscape.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CPlane;
import org.ryzom.nel.misc.CRGBA;
import org.ryzom.nel.misc.CRefCount;
import org.ryzom.nel.misc.CUV;
import org.ryzom.nel.misc.CVector;

public class CLandscape extends CRefCount {
  private long swigCPtr;

  public CLandscape(long cPtr, boolean cMemoryOwn) {
    super(nel3dJNI.CLandscape_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  public static long getCPtr(CLandscape obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CLandscape(swigCPtr);
      }
      swigCPtr = 0;
    }
    super.delete();
  }

  public void setTileBank(CTileBank value) {
    nel3dJNI.CLandscape_TileBank_set(swigCPtr, this, CTileBank.getCPtr(value), value);
  }

  public CTileBank getTileBank() {
    return new CTileBank(nel3dJNI.CLandscape_TileBank_get(swigCPtr, this), true);
  }

  public void setTileFarBank(CTileFarBank value) {
    nel3dJNI.CLandscape_TileFarBank_set(swigCPtr, this, CTileFarBank.getCPtr(value), value);
  }

  public CTileFarBank getTileFarBank() {
    return new CTileFarBank(nel3dJNI.CLandscape_TileFarBank_get(swigCPtr, this), true);
  }

  public void setOwnerModel(CLandscapeModel value) {
    nel3dJNI.CLandscape_OwnerModel_set(swigCPtr, this, CLandscapeModel.getCPtr(value), value);
  }

  public CLandscapeModel getOwnerModel() {
    long cPtr = nel3dJNI.CLandscape_OwnerModel_get(swigCPtr, this);
    return (cPtr == 0) ? null : new CLandscapeModel(cPtr, false);
  }

  public CLandscape() {
    this(nel3dJNI.new_CLandscape(), true);
  }

  public void init() {
    nel3dJNI.CLandscape_init(swigCPtr, this);
  }

  public boolean addZone(CZone newZone) {
    return nel3dJNI.CLandscape_addZone(swigCPtr, this, CZone.getCPtr(newZone), newZone);
  }

  public boolean removeZone(long zoneId) {
    return nel3dJNI.CLandscape_removeZone(swigCPtr, this, zoneId);
  }

  public void clear() {
    nel3dJNI.CLandscape_clear(swigCPtr, this);
  }

  public void checkBinds() {
    nel3dJNI.CLandscape_checkBinds__SWIG_0(swigCPtr, this);
  }

  public void checkBinds(long zoneId) {
    nel3dJNI.CLandscape_checkBinds__SWIG_1(swigCPtr, this, zoneId);
  }

  public boolean initTileBanks() {
    return nel3dJNI.CLandscape_initTileBanks(swigCPtr, this);
  }

  public void setTileNear(float tileNear) {
    nel3dJNI.CLandscape_setTileNear(swigCPtr, this, tileNear);
  }

  public float getTileNear() {
    return nel3dJNI.CLandscape_getTileNear(swigCPtr, this);
  }

  public void setThreshold(float thre) {
    nel3dJNI.CLandscape_setThreshold(swigCPtr, this, thre);
  }

  public float getThreshold() {
    return nel3dJNI.CLandscape_getThreshold(swigCPtr, this);
  }

  public void setRefineMode(boolean enabled) {
    nel3dJNI.CLandscape_setRefineMode(swigCPtr, this, enabled);
  }

  public boolean getRefineMode() {
    return nel3dJNI.CLandscape_getRefineMode(swigCPtr, this);
  }

  public void setTileMaxSubdivision(long tileDiv) {
    nel3dJNI.CLandscape_setTileMaxSubdivision(swigCPtr, this, tileDiv);
  }

  public long getTileMaxSubdivision() {
    return nel3dJNI.CLandscape_getTileMaxSubdivision(swigCPtr, this);
  }

  public void setNoiseMode(boolean enabled) {
    nel3dJNI.CLandscape_setNoiseMode(swigCPtr, this, enabled);
  }

  public boolean getNoiseMode() {
    return nel3dJNI.CLandscape_getNoiseMode(swigCPtr, this);
  }

  public void invalidateAllTiles() {
    nel3dJNI.CLandscape_invalidateAllTiles(swigCPtr, this);
  }

  public void setDriver(IDriver drv) {
    nel3dJNI.CLandscape_setDriver(swigCPtr, this, IDriver.getCPtr(drv), drv);
  }

  public void clip(CVector refineCenter, SWIGTYPE_p_std__vectorT_NLMISC__CPlane_t pyramid) {
    nel3dJNI.CLandscape_clip(swigCPtr, this, CVector.getCPtr(refineCenter), refineCenter, SWIGTYPE_p_std__vectorT_NLMISC__CPlane_t.getCPtr(pyramid));
  }

  public void refine(CVector refineCenter) {
    nel3dJNI.CLandscape_refine(swigCPtr, this, CVector.getCPtr(refineCenter), refineCenter);
  }

  public void render(CVector refineCenter, CVector frontVector, CPlane pyramid, boolean doTileAddPass) {
    nel3dJNI.CLandscape_render__SWIG_0(swigCPtr, this, CVector.getCPtr(refineCenter), refineCenter, CVector.getCPtr(frontVector), frontVector, CPlane.getCPtr(pyramid), pyramid, doTileAddPass);
  }

  public void render(CVector refineCenter, CVector frontVector, CPlane pyramid) {
    nel3dJNI.CLandscape_render__SWIG_1(swigCPtr, this, CVector.getCPtr(refineCenter), refineCenter, CVector.getCPtr(frontVector), frontVector, CPlane.getCPtr(pyramid), pyramid);
  }

  public void refineAll(CVector refineCenter) {
    nel3dJNI.CLandscape_refineAll(swigCPtr, this, CVector.getCPtr(refineCenter), refineCenter);
  }

  public void excludePatchFromRefineAll(int zoneId, long patch, boolean exclude) {
    nel3dJNI.CLandscape_excludePatchFromRefineAll(swigCPtr, this, zoneId, patch, exclude);
  }

  public void averageTesselationVertices() {
    nel3dJNI.CLandscape_averageTesselationVertices(swigCPtr, this);
  }

  public void profileRender() {
    nel3dJNI.CLandscape_profileRender(swigCPtr, this);
  }

  public CVector getOldRefineCenter() {
    return new CVector(nel3dJNI.CLandscape_getOldRefineCenter(swigCPtr, this), false);
  }

  public void buildCollideFaces(SWIGTYPE_p_CAABBoxExt bbox, SWIGTYPE_p_std__vectorT_NLMISC__CTriangle_t faces, boolean faceSplit) {
    nel3dJNI.CLandscape_buildCollideFaces__SWIG_0(swigCPtr, this, SWIGTYPE_p_CAABBoxExt.getCPtr(bbox), SWIGTYPE_p_std__vectorT_NLMISC__CTriangle_t.getCPtr(faces), faceSplit);
  }

  public void buildCollideFaces(int zoneId, int patch, SWIGTYPE_p_std__vectorT_NLMISC__CTriangle_t faces) {
    nel3dJNI.CLandscape_buildCollideFaces__SWIG_1(swigCPtr, this, zoneId, patch, SWIGTYPE_p_std__vectorT_NLMISC__CTriangle_t.getCPtr(faces));
  }

  public void buildTrianglesInBBox(SWIGTYPE_p_CAABBox bbox, SWIGTYPE_p_std__vectorT_CTrianglePatch_t triangles, short tileTessLevel) {
    nel3dJNI.CLandscape_buildTrianglesInBBox(swigCPtr, this, SWIGTYPE_p_CAABBox.getCPtr(bbox), SWIGTYPE_p_std__vectorT_CTrianglePatch_t.getCPtr(triangles), tileTessLevel);
  }

  public void buildPatchBlocksInBBox(SWIGTYPE_p_CAABBox bbox, SWIGTYPE_p_std__vectorT_CPatchBlockIdent_t paBlockIds) {
    nel3dJNI.CLandscape_buildPatchBlocksInBBox(swigCPtr, this, SWIGTYPE_p_CAABBox.getCPtr(bbox), SWIGTYPE_p_std__vectorT_CPatchBlockIdent_t.getCPtr(paBlockIds));
  }

  public void fillPatchQuadBlock(CPatchQuadBlock quadBlock) {
    nel3dJNI.CLandscape_fillPatchQuadBlock(swigCPtr, this, CPatchQuadBlock.getCPtr(quadBlock), quadBlock);
  }

  public CVector getTesselatedPos(CPatchIdent patchId, CUV uv) {
    return new CVector(nel3dJNI.CLandscape_getTesselatedPos(swigCPtr, this, CPatchIdent.getCPtr(patchId), patchId, CUV.getCPtr(uv), uv), true);
  }

  public void getTessellationLeaves(SWIGTYPE_p_std__vectorT_CTessFace_const_p_t leaves) {
    nel3dJNI.CLandscape_getTessellationLeaves(swigCPtr, this, SWIGTYPE_p_std__vectorT_CTessFace_const_p_t.getCPtr(leaves));
  }

  public float getCameraCollision(CVector start, CVector end, float radius, boolean cone) {
    return nel3dJNI.CLandscape_getCameraCollision(swigCPtr, this, CVector.getCPtr(start), start, CVector.getCPtr(end), end, radius, cone);
  }

  public float getRayCollision(CVector start, CVector end) {
    return nel3dJNI.CLandscape_getRayCollision(swigCPtr, this, CVector.getCPtr(start), start, CVector.getCPtr(end), end);
  }

  public CZone getZone(int zoneId) {
    long cPtr = nel3dJNI.CLandscape_getZone__SWIG_0(swigCPtr, this, zoneId);
    return (cPtr == 0) ? null : new CZone(cPtr, false);
  }

  public void getZoneList(Vector_uint16 zoneIds) {
    nel3dJNI.CLandscape_getZoneList(swigCPtr, this, Vector_uint16.getCPtr(zoneIds), zoneIds);
  }

  public static void buildZoneName(int zoneId, SWIGTYPE_p_std__string zoneName) {
    nel3dJNI.CLandscape_buildZoneName(zoneId, SWIGTYPE_p_std__string.getCPtr(zoneName));
  }

  public void flushTiles(IDriver drv, long tileStart, long nbTiles) {
    nel3dJNI.CLandscape_flushTiles(swigCPtr, this, IDriver.getCPtr(drv), drv, tileStart, nbTiles);
  }

  public void releaseTiles(long tileStart, long nbTiles) {
    nel3dJNI.CLandscape_releaseTiles(swigCPtr, this, tileStart, nbTiles);
  }

  public void releaseAllTiles() {
    nel3dJNI.CLandscape_releaseAllTiles(swigCPtr, this);
  }

  public SWIGTYPE_p_NLMISC__CSmartPtrT_NL3D__ITexture_t getTileTexture(long tileId, SWIGTYPE_p_CTile__TBitmap bitmapType, CVector uvScaleBias) {
    return new SWIGTYPE_p_NLMISC__CSmartPtrT_NL3D__ITexture_t(nel3dJNI.CLandscape_getTileTexture(swigCPtr, this, tileId, SWIGTYPE_p_CTile__TBitmap.getCPtr(bitmapType), CVector.getCPtr(uvScaleBias), uvScaleBias), true);
  }

  public CTileElement getTileElement(CPatchIdent patchId, CUV uv) {
    long cPtr = nel3dJNI.CLandscape_getTileElement(swigCPtr, this, CPatchIdent.getCPtr(patchId), patchId, CUV.getCPtr(uv), uv);
    return (cPtr == 0) ? null : new CTileElement(cPtr, false);
  }

  public void setupStaticLight(CRGBA diffuse, CRGBA ambiant, float multiply) {
    nel3dJNI.CLandscape_setupStaticLight(swigCPtr, this, CRGBA.getCPtr(diffuse), diffuse, CRGBA.getCPtr(ambiant), ambiant, multiply);
  }

  public CRGBA getStaticLight() {
    long cPtr = nel3dJNI.CLandscape_getStaticLight(swigCPtr, this);
    return (cPtr == 0) ? null : new CRGBA(cPtr, false);
  }

  public void setPointLightDiffuseMaterial(CRGBA diffuse) {
    nel3dJNI.CLandscape_setPointLightDiffuseMaterial(swigCPtr, this, CRGBA.getCPtr(diffuse), diffuse);
  }

  public CRGBA getPointLightDiffuseMaterial() {
    return new CRGBA(nel3dJNI.CLandscape_getPointLightDiffuseMaterial(swigCPtr, this), true);
  }

  public void enableAutomaticLighting(boolean enable) {
    nel3dJNI.CLandscape_enableAutomaticLighting(swigCPtr, this, enable);
  }

  public void setupAutomaticLightDir(CVector lightDir) {
    nel3dJNI.CLandscape_setupAutomaticLightDir(swigCPtr, this, CVector.getCPtr(lightDir), lightDir);
  }

  public boolean getAutomaticLighting() {
    return nel3dJNI.CLandscape_getAutomaticLighting(swigCPtr, this);
  }

  public CVector getAutomaticLightDir() {
    return new CVector(nel3dJNI.CLandscape_getAutomaticLightDir(swigCPtr, this), false);
  }

  public void removeAllPointLights() {
    nel3dJNI.CLandscape_removeAllPointLights(swigCPtr, this);
  }

  public void setPointLightFactor(CScene scene) {
    nel3dJNI.CLandscape_setPointLightFactor(swigCPtr, this, CScene.getCPtr(scene), scene);
  }

  public void initAnimatedLightIndex(CScene scene) {
    nel3dJNI.CLandscape_initAnimatedLightIndex(swigCPtr, this, CScene.getCPtr(scene), scene);
  }

  public CVector getHeightFieldDeltaZ(float x, float y) {
    return new CVector(nel3dJNI.CLandscape_getHeightFieldDeltaZ(swigCPtr, this, x, y), true);
  }

  public void setHeightField(CHeightMap hf) {
    nel3dJNI.CLandscape_setHeightField(swigCPtr, this, CHeightMap.getCPtr(hf), hf);
  }

  public void createVegetableBlendLayersModels(CScene scene) {
    nel3dJNI.CLandscape_createVegetableBlendLayersModels(swigCPtr, this, CScene.getCPtr(scene), scene);
  }

  public void setVegetableTime(double time) {
    nel3dJNI.CLandscape_setVegetableTime(swigCPtr, this, time);
  }

  public void setVegetableUpdateLightingTime(double time) {
    nel3dJNI.CLandscape_setVegetableUpdateLightingTime(swigCPtr, this, time);
  }

  public void enableVegetable(boolean enable) {
    nel3dJNI.CLandscape_enableVegetable(swigCPtr, this, enable);
  }

  public boolean isVegetableActive() {
    return nel3dJNI.CLandscape_isVegetableActive(swigCPtr, this);
  }

  public void loadVegetableTexture(String textureFileName) {
    nel3dJNI.CLandscape_loadVegetableTexture(swigCPtr, this, textureFileName);
  }

  public void setupVegetableLighting(CRGBA ambient, CRGBA diffuse, CVector directionalLight) {
    nel3dJNI.CLandscape_setupVegetableLighting(swigCPtr, this, CRGBA.getCPtr(ambient), ambient, CRGBA.getCPtr(diffuse), diffuse, CVector.getCPtr(directionalLight), directionalLight);
  }

  public void setVegetableWind(CVector windDir, float windFreq, float windPower, float windBendMin) {
    nel3dJNI.CLandscape_setVegetableWind(swigCPtr, this, CVector.getCPtr(windDir), windDir, windFreq, windPower, windBendMin);
  }

  public long getNumVegetableFaceRendered() {
    return nel3dJNI.CLandscape_getNumVegetableFaceRendered(swigCPtr, this);
  }

  public void setVegetableUpdateLightingFrequency(float freq) {
    nel3dJNI.CLandscape_setVegetableUpdateLightingFrequency(swigCPtr, this, freq);
  }

  public void setupColorsFromTileFlags(CRGBA colors) {
    nel3dJNI.CLandscape_setupColorsFromTileFlags(swigCPtr, this, CRGBA.getCPtr(colors), colors);
  }

  public void setVegetableDensity(float density) {
    nel3dJNI.CLandscape_setVegetableDensity(swigCPtr, this, density);
  }

  public float getVegetableDensity() {
    return nel3dJNI.CLandscape_getVegetableDensity(swigCPtr, this);
  }

  public short getLumel(CPatchIdent patchId, CUV uv) {
    return nel3dJNI.CLandscape_getLumel(swigCPtr, this, CPatchIdent.getCPtr(patchId), patchId, CUV.getCPtr(uv), uv);
  }

  public void appendTileLightInfluences(CPatchIdent patchId, CUV uv, SWIGTYPE_p_std__vectorT_CPointLightInfluence_t pointLightList) {
    nel3dJNI.CLandscape_appendTileLightInfluences(swigCPtr, this, CPatchIdent.getCPtr(patchId), patchId, CUV.getCPtr(uv), uv, SWIGTYPE_p_std__vectorT_CPointLightInfluence_t.getCPtr(pointLightList));
  }

  public void setPZBModelPosition(CVector pos) {
    nel3dJNI.CLandscape_setPZBModelPosition(swigCPtr, this, CVector.getCPtr(pos), pos);
  }

  public CVector getPZBModelPosition() {
    return new CVector(nel3dJNI.CLandscape_getPZBModelPosition(swigCPtr, this), false);
  }

  public void updateLighting(double time) {
    nel3dJNI.CLandscape_updateLighting(swigCPtr, this, time);
  }

  public void setUpdateLightingFrequency(float freq) {
    nel3dJNI.CLandscape_setUpdateLightingFrequency(swigCPtr, this, freq);
  }

  public void updateLightingAll() {
    nel3dJNI.CLandscape_updateLightingAll(swigCPtr, this);
  }

  public void computeDynamicLighting(SWIGTYPE_p_std__vectorT_CPointLight_p_t pls) {
    nel3dJNI.CLandscape_computeDynamicLighting(swigCPtr, this, SWIGTYPE_p_std__vectorT_CPointLight_p_t.getCPtr(pls));
  }

  public long getDynamicLightingMemoryLoad() {
    return nel3dJNI.CLandscape_getDynamicLightingMemoryLoad(swigCPtr, this);
  }

  public void setDynamicLightingMaxAttEnd(float maxAttEnd) {
    nel3dJNI.CLandscape_setDynamicLightingMaxAttEnd(swigCPtr, this, maxAttEnd);
  }

  public float getDynamicLightingMaxAttEnd() {
    return nel3dJNI.CLandscape_getDynamicLightingMaxAttEnd(swigCPtr, this);
  }

  public void setDLMGlobalVegetableColor(CRGBA gvc) {
    nel3dJNI.CLandscape_setDLMGlobalVegetableColor(swigCPtr, this, CRGBA.getCPtr(gvc), gvc);
  }

  public CRGBA getDLMGlobalVegetableColor() {
    return new CRGBA(nel3dJNI.CLandscape_getDLMGlobalVegetableColor(swigCPtr, this), true);
  }

  public void receiveShadowMap(IDriver drv, CShadowMap shadowMap, CVector casterPos, CMaterial shadowMat, CVector pzb) {
    nel3dJNI.CLandscape_receiveShadowMap(swigCPtr, this, IDriver.getCPtr(drv), drv, CShadowMap.getCPtr(shadowMap), shadowMap, CVector.getCPtr(casterPos), casterPos, CMaterial.getCPtr(shadowMat), shadowMat, CVector.getCPtr(pzb), pzb);
  }

  public void addTileCallback(ULandscapeTileCallback cb) {
    nel3dJNI.CLandscape_addTileCallback(swigCPtr, this, ULandscapeTileCallback.getCPtr(cb), cb);
  }

  public void removeTileCallback(ULandscapeTileCallback cb) {
    nel3dJNI.CLandscape_removeTileCallback(swigCPtr, this, ULandscapeTileCallback.getCPtr(cb), cb);
  }

  public boolean isTileCallback(ULandscapeTileCallback cb) {
    return nel3dJNI.CLandscape_isTileCallback(swigCPtr, this, ULandscapeTileCallback.getCPtr(cb), cb);
  }

  public SWIGTYPE_p_std__vectorT_NL3D__ULandscapeTileCallback_p_t getTileCallbacks() {
    return new SWIGTYPE_p_std__vectorT_NL3D__ULandscapeTileCallback_p_t(nel3dJNI.CLandscape_getTileCallbacks(swigCPtr, this), false);
  }

  public void lockBuffers() {
    nel3dJNI.CLandscape_lockBuffers(swigCPtr, this);
  }

  public void unlockBuffers(boolean force) {
    nel3dJNI.CLandscape_unlockBuffers__SWIG_0(swigCPtr, this, force);
  }

  public void unlockBuffers() {
    nel3dJNI.CLandscape_unlockBuffers__SWIG_1(swigCPtr, this);
  }

  public boolean isLocked() {
    return nel3dJNI.CLandscape_isLocked(swigCPtr, this);
  }

  public CShadowPolyReceiver getShadowPolyReceiver() {
    return new CShadowPolyReceiver(nel3dJNI.CLandscape_getShadowPolyReceiver(swigCPtr, this), false);
  }

  public void setZFunc(CMaterial.ZFunc val) {
    nel3dJNI.CLandscape_setZFunc(swigCPtr, this, val.swigValue());
  }

}
